Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • asdocx | table 1: Patient baseline characteristics table commonly found in biomedical

    For asdocx users!
    In the recent update of asdocx, I have added table1 to the asdocx package. You can read this page https://fintechprofessor.com/asdocx/...tients-asdocx/ for more details . A short summary is presented here.

    The table 1 template

    The table1 template is an asdocx package that creates “Table 1”, i.e., patient baseline characteristics table commonly found in biomedical research papers. The template can summarize different types of variables such as continuous and categorical variables in a single table.

    How to Use it

    The template is free. However, it requires asdocx package, that is currently available at 80% discount for a limited time. To use this template, first you need to install it.
    Code:
    Code:
      net install asdocx_addins, from(http://fintechprofessor.com/asdocxAddins) replace
    After installation of the template, you can use the template as shown below.
    Code:
    * Load example dataset
    use http://fintechprofessor.com/asdocxAddins/table1.dta, clear 
    
    * Make table 1 using the template(table1) option 
    asdocx tab immigrant bone_arthritis bone_backspin              ///
           bone_backother bone_neck bone_fibro bone_lupus          ///
           bone_ehlers bone_deform bone_amp bone_burn nervous_ms   ///
           nervous_seizure nervous_park nervous_stroke             ///
           other_otherhealth other_anyother ,                      ///
           template(table1) table_layout(autofit) replace

    Notes:
    1. After the command tab, we shall use the treatment variable followed by all basic characteristics variables. We can add as many variables as needed.

    2. Please note the text template(table1), addition of this option invokes the table1 template.

    3. I am also using the option table_layout(autofit) to get a tight auto fit of contents for the table.

    The template should generate a table as the one shown below:

    Last edited by Attaullah Shah; 18 Jan 2021, 03:46.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

  • #2
    The template for table1 has been updated. With the new updates, we can now specify various statistics with binary, categorical, and continuous variables. Also, the updated template accepts svy: prefix to reported survey weighted statistics. See more details and examples here https://fintechprofessor.com/asdocx/...tients-asdocx/
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Hello Professor Shah
      I must appreciate the aesthetic output of the template. I have one question. How can I change the decimal points of the p-values?

      Comment


      • #4
        You can use the option dect(). Therefore, if 4 decimal points are needed, use dect(4).
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          I have updated the template(table1) in asdocx. Several asdocx's users requested to add support for multiple categories of the treatment variable. In asdocx version 2.1.2 (Aug 17, 2022) this is now possible. The updates are still in the beta stage, therefore, asdocx users should update to the beta version of asdocx. Detailed examples are presented on this page.
          Regards
          --------------------------------------------------
          Attaullah Shah, PhD.
          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
          FinTechProfessor.com
          https://asdocx.com
          Check out my asdoc program, which sends outputs to MS Word.
          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

          Comment


          • #6
            Hi Dr. Shah -- loving asdocx. Thank you! I know I can create my own templates for future use, but I wonder: is there a way to directly edit the existing Table1 Template as a starting point? I looked for the distinct .ado file, but couldn't find it. I did notice some code buried in the primary asdocx.ado file, but I don't want to mess with that!

            Comment


            • #7
              Hello Kevin
              I shall not suggest using the table1 template as a starting point for creating templates as it is way too complex. There is a half-written tutorial on how to create template files, thanks for your interest, I shall try to complete it in a week or so (link https://fintechprofessor.com/asdocx/...template-files ). If you must work with a working template, I would suggest the reg1 template as it is relatively simple. You can follow these steps to modify it and create something new

              1. Copy the following code to a new do file, save it as asdocx_mytemplate.ado file, where mytemplate will be your template name. Save this file along the ado path in folder a. Please note the program name is also asdocx_mytemplat.
              Code:
              *-----------------------------------------------------------------------------
              * Custom Regression table for Epidemiologists
              * Version 1.3: March 14, 2021: by Attaullah Shah
              *-----------------------------------------------------------------------------
              
              program define asdocx_mytemplat
              
                  if strmatch("`0'", "*:*") |  strmatch("`0'", "* :*") | strmatch("`0'", "*: *") | strmatch("`0'", "* : *") {
                      cap _on_colon_parse `0'
                      local 0 `"`s(after)'"'
                      local prefix `"`s(before)'"'
                      if ("`prefix'" != "") loc prefix `prefix' :
              
                  }
              
                  syntax anything [if] [in] [fw pw iw aw] , [title(str) notes(str) modifytype(str) ///
                      dect(str) dec(str) btp *]
              
              
                  if ("`dect'" == "") loc dect `dec'
              
                  if ("$modifytype" == "replace") {
                      cap rm $active_flexmat_file
                      loc location 1
                  }
              
                  else {
                      flexmat showmat ,  filename($active_flexmat_file) qui getlocinfo
              
                      if ("$flexmat_current_loc" == "") {
                          loc location 1
                      }
              
                      else loc location = $flexmat_current_loc + 1
                  }
              
                  * Write the title row
                  flexmat addrow, data(Variable, OR [95% CI], P-value) ///
                      row(`ThisRow') filename($active_flexmat_file) location(`location') qui
              
                  loc ThisRow = 2
              
                  if ("`weight'" != "") loc wgt "[`weight'`exp']"
              
               * run and show the Stata command output
                  `prefix'  `anything' `if' `in' `wgt' , `options'
              
                  
                  loc depvar `e(depvar)'
                  loc N `e(N)'
                  matrix table = r(table)
                  local varnames : colfullnames table
                  loc nvars : word count `varnames'
              
                  loc c = 1
              
                  foreach v of local varnames {
              
                      loc hzratio : dis %9.`dec'f = table[1, `c']
                      loc ll : dis %9.`dec'f = table[5,`c']
                      loc ul : dis %9.`dec'f = table[6,`c']
                      loc pvalue : dis %9.`dect'f = table[4,`c']
              
                      loc hzratio `hzratio' [`ll'\comma `ul']
              
                      forv i = 1 / 6 {
                          loc hzratio = subinstr("`hzratio'", "[ ", "[", .)
                      }
              
                      if ("`btp'" != "") {
                          loc hzratio = subinstr("`hzratio'", "[", "\openpar", .)
                          loc hzratio = subinstr("`hzratio'", "]", "\closepar", .)
              
                      }
              
                      loc v = subinstr("`v'", "`e(depvar)':", "", .)
              
                      if strmatch("`v'", "*b.*") {
                          loc hzratio
                          loc pvalue
                      }
                      mata: st_local("varLabel", getlable("`v'"))
                      loc varLabel = subinstr("`varLabel'", ",", "\comma", .)
                      loc varLabel = subinstr("`varLabel'", "_cons", "Constant", .)
              
                      if ("`varLabel'" == "Constant" & "${drop}" == "constant") continue
                      else {
              
                          flexmat addrow, data("`varLabel'", `hzratio', `pvalue' ) qui ///
                              row(`ThisRow') filename($active_flexmat_file) location(`location')
              
                          loc `++ThisRow'
                          loc `++c'
              
                      }
                  }
                  flexmat addrow, data(Observations, , `N' ) qui ///
                      row(`ThisRow') filename($active_flexmat_file) location(`location')
              
                  if ("`title'" == "") loc title Table: Regression Results - `depvar'
                  if ("`notes'" == "") loc notes "Notes:"
              
                  * Add notes and table title: flexmat_fmtmat stores all table related info
                  mata {
                      flexmat_fmtmat = J(2,2,"")
                      flexmat_fmtmat[1,1] = "title"
                      flexmat_fmtmat[1,2] = "`title'"
                      flexmat_fmtmat[2,1] = "notes"
                      flexmat_fmtmat[2,2] = "`notes'"    
                  }
                  flexmat fmtmat, file("$active_flexmat_file") loc(`location')  hide    
              
                  glob drop
              end
              2. Call this template from asdocx using option template(mytemplate). Say, the template uses regression command,
              Code:
               asdocx reg depvar indepvars, title(text) dec(#) dect(#) template(mytemplate)
              Last edited by Attaullah Shah; 05 Nov 2022, 23:11.
              Regards
              --------------------------------------------------
              Attaullah Shah, PhD.
              Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
              FinTechProfessor.com
              https://asdocx.com
              Check out my asdoc program, which sends outputs to MS Word.
              For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

              Comment


              • #8
                Thanks Dr. Shah -- this is super helpful!

                Comment


                • #9
                  The tutorial on writing a template file is complete now. You may access it here https://fintechprofessor.com/asdocx/...emplate-files/
                  Regards
                  --------------------------------------------------
                  Attaullah Shah, PhD.
                  Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                  FinTechProfessor.com
                  https://asdocx.com
                  Check out my asdoc program, which sends outputs to MS Word.
                  For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                  Comment


                  • #10
                    Thank you!

                    One more question regarding Table 1 template: is there a way to exclude the treatment variable or to just return the Total column with no p-values, since there's no comparison? I basically want to do "asdocx tab", but with multiple variables like Table 1, but only frequencies. Is a foreach loop the better option here?

                    It seems like perhaps the best route would be the use community-program "fre", but upon trying with asdocx, it doesn't seem to be compatible. Any help would be appreciated!
                    Last edited by Kevin Blaine; 16 Nov 2022, 11:17.

                    Comment


                    • #11
                      Thank you! I am loving asdocx and the table1 template. One question: I have tried to create a survey-weighted table of patient's characteristics, both with my own data and by recreating the examples given on your website. While the command itself works smoothly, the percentages seem not to be survey-weighted. The output basically shows the same results as I would just create a two-way table without weights. Is there any troubleshooting I could try?

                      Edit: I am using Stata version 17.0
                      Last edited by Julian Kroll; 09 Jul 2023, 11:06.

                      Comment


                      • #12
                        Hello Julian Krol
                        Thanks for your feedback. Can you please send me the code and data so that I can identify the source of the issue.
                        Regards
                        --------------------------------------------------
                        Attaullah Shah, PhD.
                        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                        FinTechProfessor.com
                        https://asdocx.com
                        Check out my asdoc program, which sends outputs to MS Word.
                        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                        Comment

                        Working...
                        X